package com.Service.impl;

import com.Service.SheetService;
import com.dao.SheetMapper;
import com.model.pojo.Examinationproject;
import com.model.pojo.Sheet;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Component
public class SheetServiceImpl implements SheetService {
@Resource
private  SheetMapper sheetMapper;
@Resource
private  Sheet sheet;
    @Override
//    @Transactional
    public boolean printInput(List<Sheet> sheetList) {

        boolean bl=false;

        List<Sheet> selectSheet =sheetMapper.selectSheet(sheetList.get(0).getSheetDimensioncode());

      if(selectSheet.size()<=0){
            for (int i=0;i<sheetList.size();i++){
                sheet=new Sheet();
                sheet.setListingSerialNumber(sheetList.get(i).getListingSerialNumber());
                sheet.setSheetDepartment(sheetList.get(i).getSheetDepartment());
                sheet.setSheetDimensioncode(sheetList.get(i).getSheetDimensioncode());
                sheet.setSheetProject(sheetList.get(i).getSheetProject());
                sheet.setSheetName(sheetList.get(i).getSheetName());
                sheet.setSheetSex(sheetList.get(i).getSheetSex());
                bl=  sheetMapper.printInput(sheet);
            }
        }else{
          bl=true;
      }
        return bl;
    }

    @Override
    public List<Sheet> summary(String roomName,String val) {

        return sheetMapper.summary(roomName,"已接收",val);
    }

    @Override
    public List<Examinationproject> details(String Dimensioncode) {
        return sheetMapper.details(Dimensioncode);
    }

    @Override
    @Transactional
    public boolean printSummary(List<Examinationproject> ExaminationprojectList, String summary) {
        boolean bl=false;
        bl=sheetMapper.printSummary(ExaminationprojectList.get(0).getMedicalSheetId(),ExaminationprojectList.get(0).getExaminationprojectId(),ExaminationprojectList.get(0).getExaminationprojectProjectName(),summary);
        bl=sheetMapper.updateprintSummary(ExaminationprojectList.get(0).getMedicalSheetId());

        return bl;
    }


    @Override
    public List<Sheet> findSheet() {//欢华
        return sheetMapper.findSheet();
    }

    @Override
    public boolean upadteById(Integer id) {

        boolean flag= sheetMapper.upadteById(id);

        return flag;
    }
}
